package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验：
 * 1. use StringTokenizer for input and StringBuffer for output, 
 * will increase performance.
 * 
 * 教训：
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2503 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2503.class.getResource("P2503.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));
		
		String line = stdin.readLine();
		Map<String, String> maps = new HashMap<String, String>();
		while (line != null && line.trim().length() > 0) {
			StringTokenizer st = new StringTokenizer(line.trim());
			String value = st.nextToken();
			String key = st.nextToken();
			maps.put(key, value);
			line = stdin.readLine();
		}
		
		line = stdin.readLine().trim();
		StringBuffer output = new StringBuffer("");
		while (line != null && line.length() > 0) {
			String value = maps.get(line);
			if (value == null) {
				output.append("eh\n");
			} else {
				output.append(value).append("\n");
			}
			line = stdin.readLine();
		}
		System.out.println(output);
	}
}
